/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package model;

import bean.LoginActionFormBean;
import dao.RegisterDao;
import java.sql.Connection;
import pojo.Register;

/**
 *
 * @author javauser
 */
public class LoginOperations {
    private Connection conn;
    
    public LoginOperations(Connection conn) {
        this.conn = conn;
    }

    public Register exists(LoginActionFormBean userBean) {
        EncryptPassword ep=new EncryptPassword();
        ep.setPassword(userBean.getPassword());
        String userbeanpass=ep.getPassword();
        System.out.println("User Bean Password is : "+userbeanpass);
        RegisterDao registerDao = new RegisterDao(conn);
        Register registeredUser = registerDao.getByUsername(userBean.getUserName());
        if (registeredUser != null) {
            if (registeredUser.getPassword().equals(userbeanpass)) {
                System.out.println("Valid Data");
                return registeredUser;
            }
            else
                System.out.println("Invalid Password ");
        }
        return null;
    }
}
